/**
 * All Rights Reserved , Copyright (C) 2022 , 青岛鼎信通讯股份有限公司
 *
 *MpmProjectBidFullScoreController
 * 评标细则总分表
 *
 * 修改纪录
 * 2022-05-13 版本：1.0 hudeyong 创建。
 * @version 版本：1.0
 * @author 作者：hudeyong
 * 创建日期：2022-05-13
 */

package com.topscomm.mpm.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.topscomm.mpm.controller.auto.MpmProjectBidFullScoreControllerAuto;
import com.topscomm.mpm.pojo.MpmProjectBidFullScoreEntity;
import com.topscomm.pub.util.ConvertUtil;
import com.topscomm.pub.util.StringBufferProxy;
import com.topscomm.pub.util.StringUtil;
import com.topscomm.pub.vo.ResponseResult;

import oracle.net.aso.b;

/**
 * @author: hudeyong
 * @date: 2022-05-13
 * @description:评标细则总分表Controller
 * @modify:
 */
@RestController
@RequestMapping("mpm/projectBidFullScore")
public class MpmProjectBidFullScoreController extends MpmProjectBidFullScoreControllerAuto implements IMpmProjectBidFullScoreController {
	/**
	 * @author: hudeyong
	 * @date: 2022-05-13
	 * @param paraMap
	 * @return
	 * @description:转换出查询SQL语句
	 * @modify:
	 */
	@Override
	protected String spellListSql(Map<String, Object> paraMap) {
		StringBufferProxy sql = new StringBufferProxy();
		sql.appendSingle(" 1=1 ");
		if (paraMap.containsKey("qry_name")) {
			String value = paraMap.get("qry_name").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and name like '%{0}%' ", value);
		}
		if (paraMap.containsKey("qry_code")) {
			String value = paraMap.get("qry_code").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and code = '{0}' ", value);
		}
		return sql.toString();
	}

	/**
	 * @author: hudeyong
	 * @date: 2022-05-13
	 * @param paraMap
	 * @return
	 * @description:转换出查询SQL语句
	 * @modify:
	 */
	@Override
	@GetMapping(value = "/refList")
	public ResponseResult<Object> refList(@RequestParam(required = false) Map<String, Object> paraMap) {
		return super.refList(paraMap);
	}

	/**
	 * @param map
	 * @return
	 * @description:新增和保存功能
	 * @author: hdy
	 * @date: 2022年5月13日
	 * @modify:
	 */
	@RequestMapping(method = { RequestMethod.POST, RequestMethod.PUT }, value = "doSave")
	public ResponseResult<Object> doSave(@RequestBody(required = false) Map<String, Object> map) {
		try {
			this.service.doSave(map);
			return ResponseResult.ok("");
		} catch (Exception e) {
			return handleControllerException(e);

		}
	}

	/**
	 * @author: hudeyong
	 * @date: 2022-05-13
	 * @param paraMap
	 * @return
	 * @description:
	 * @modify:
	 */
	@GetMapping(value = "/fullScoreInfo")
	public ResponseResult<Object> fullScoreInfo(@RequestParam(required = false) Map<String, Object> paraMap) {
		String projectcode = ConvertUtil.convertToString(paraMap.get("projectcode"));
		String type = ConvertUtil.convertToString(paraMap.get("type"));
		String times = ConvertUtil.convertToString(paraMap.get("times"));
		StringBufferProxy sql = new StringBufferProxy();
		sql.appendSingle("type = '{0}' and times = '{1}' and projectcode = '{2}'",
				type,times,projectcode);
		List<MpmProjectBidFullScoreEntity> mpmProjectBidFullScoreEntities = this.service.queryByWhere(sql.toString());
		Map<String, Object> resultMap;
		if(mpmProjectBidFullScoreEntities.size()>0) {
			resultMap = mpmProjectBidFullScoreEntities.get(0).convertToMap();
		} else {
			resultMap = new HashMap<>();
		}
		return ResponseResult.ok(resultMap);
	}
}

